package TCP.Test;

import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Server1 {
    public static void main(String[] args) throws Exception {
        ServerSocket serverSocket = new ServerSocket(8888);
        while (true) {
            Socket socket = serverSocket.accept();
            InputStream is = socket.getInputStream();
            OutputStream os = null;
            int len;
            byte[] b = new byte[1024];
            while ((len = is.read(b)) != -1) {
                String s = new String(b, 0, len);
                System.out.println(s);
                if (s.equals("admin123")) {
                    os = socket.getOutputStream();
                    os.write("登录成功！".getBytes());
                } else {
                    os = socket.getOutputStream();
                    os.write("登录失败！".getBytes());
                }
            }
        }
    }
}
